﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace AspDotNet.Framework.Mvc.FirstDemo.Models
{
    public class Person
    {
        public int id { get; set; }
        [Required]
        [MinLength(3)]
        [MaxLength(50)]
        [DisplayName(displayName: "姓名")]
        [RegularExpression(
            pattern: @"[\w\d .]+",
            ErrorMessage = "Name cannot contain bala bala",
            ErrorMessageResourceName = null,
            ErrorMessageResourceType = null,
            MatchTimeoutInMilliseconds = 3000)]
        public string name { get; set; }
        [Range(0, 200)]
        [DisplayName(displayName: "年龄")]
        public int age { get; set; }
        [MinLength(5)]
        [MaxLength(500)]
        [DisplayName(displayName: "地址")]
        public string address { get; set; }
        [Phone, Required(ErrorMessage = "电话为必填项")]
        [DisplayName(displayName: "电话")]
        [Display(AutoGenerateField = true)]
        public string phone { get; set; }

        [Required]
        [StringLength(maximumLength: 50)]
        [EmailAddress]
        [DisplayName(displayName: "邮箱")]
        public string email { get; set; }

        [DisplayName(displayName: "职业")]
        [Display(AutoGenerateField = true)]
        public string professional { get; set; }

        [Editable(allowEdit: false)]
        public string idCard { get; set; }
        [CreditCard]
        public string bankCard { get; set; }
        /// <summary>
        /// 个人档案
        /// </summary>
        [FileExtensions(Extensions = "txt,doc,docx")]
        public string profile { get; set; }


        public static List<Person> People { get; set; } = new List<Person>()
        {
            new Person()
            {
                id = 1,
                address = "xxx xxx",
                age = 18,
                bankCard = "1234567890",
                email = "xxx@email.com",
                idCard = "1111222233333",
                name = "william",
                phone = "1234567890",
                professional = "doctor",
                profile = "xxx.doc"
            },
            new Person()
            {
                id = 2,
                address = "xxx xxx",
                age = 18,
                bankCard = "1234567890",
                email = "xxx@email.com",
                idCard = "1111222233333",
                name = "Tom",
                phone = "1234567890",
                professional = "doctor",
                profile = "xxx.doc"
            },
        };
    }
}